import os

class CopCopy:
    def __init__(self, path, dpath) -> None:
        self.path = path
        self.dpath = dpath
    def _copy_base(self):
        print('[---] Copying base files')
        os.system(f'cp -r {self.path}config/autostart {self.dpath}.config/')
        os.system(f'cp -r {self.path}config/gtk-2.0 {self.dpath}.config/')
        os.system(f'cp -r {self.path}config/gtk-3.0 {self.dpath}.config/')
        os.system(f'cp -r {self.path}config/gtk-3.0 {self.dpath}.config/gtk-4.0')
        os.system(f'sudo cp -r {self.path}config/gtk-2.0 /root/.config/')
        os.system(f'sudo cp -r {self.path}config/gtk-3.0 /root/.config/')
        os.system(f'sudo cp -r {self.path}config/gtk-3.0 /root/.config/gtk-4.0')
        CopCopy(path=self.path, dpath=self.dpath).__create_bookms()
        os.system(f'cp -r {self.path}hypr/hyprland.conf {self.dpath}.config/hypr/hyprland.conf')
        os.system(f'cp -r {self.path}hypr/wofi {self.dpath}.config/hypr/')
        os.system(f'cp -r {self.path}gtkrc-2.0 {self.dpath}.gtkrc-2.0')
        os.system(f'cp -r {self.path}ggt {self.dpath}.config/hypr/ggt')
        os.system(f'chmod +x {self.dpath}.config/hypr/ggt')
        os.system(f'sudo cp -r {self.path}gtkrc-2.0 /root/.gtkrc-2.0')
        os.system(f'cp -r {self.path}rmwr.py {self.dpath}.config/hypr/rmwr.py')
        os.system(f'cp -r {self.path}config/dunst {self.dpath}.config/')
        os.system('chmod +x {self.dpath}.config/dunst/alert')
        os.system('chmod +x {self.path}ggt')
        os.system('cp -r {self.path}walpapers/0.png {self.dpath}Pictures/walpapes/')
        print('[+] Copy base files')
    def _copylap(self):
        print('[---] Copying lap files')
        os.system(f'cp -r {self.path}hypr/lapway/waybar-config {self.dpath}.config/hypr/')
        os.system(f'sudo cp -r {self.path}startint /etc/init.d/startint')
        os.system("sudo chmod +x /etc/init.d/startint")
        print('[+] Copy lap files')
    def _copypc(self):
        print('[---] Copying pc files')
        os.system(f'cp -r {self.path}hypr/pcway/waybar-config {self.dpath}.config/hypr/')
        print('[+] Copy pc files')
    def _copyother(self):
        print('[---] Copying other files')
        os.system(f'sudo cp -r {self.path}BeautyDream/ /usr/share/icons/')
        os.system(f'sudo cp -r {self.path}Sunity-cursors/ /usr/share/icons/')
        os.system(f'sudo cp -r {self.path}icons {self.dpath}.icons')
        os.system(f'sudo cp -r {self.path}bin/qalculate /usr/bin/qalculate')
        os.system('sudo chmod +x /usr/bin/qalculate')
        os.system(f'sudo cp -r {self.path}qalculate-gtk.desktop /usr/share/applications/')
        os.system(f'sudo cp -r {self.path}Layan-Dark/ /usr/share/themes/')
        os.system(f'sudo cp -r {self.path}fonts/ /usr/share/fonts')
        os.system(f'sudo cp -r {self.path}bin/* /usr/bin/')
        os.system('sudo chmod +x /usr/bin/hypr-kbd-layout')
        os.system('sudo chmod +x /usr/bin/screen')
        os.system('sudo chmod +x /usr/bin/wofi-power-menu')
        print('[+] Copy other files')
    def _copyetcher(self):
        print('[---] Copying etcher file')
        os.system(f'sudo cp -r {self.path}balena-etcher.desktop /usr/share/applications/')
        print('[+] Copy etcher file')
    def __create_bookms(self):
        with open(f'{self.dpath}.config/gtk-3.0/bookmarks', 'w+') as file:
            file.write(f'file://{self.dpath}Projects\nfile://{self.dpath}Documents\nfile://{self.dpath}Music\nfile://{self.dpath}Pictures\nfile://{self.dpath}Videos\nfile://{self.dpath}Downloads')
        os.system(f'cp -r {self.dpath}.config/gtk-3.0/bookmarks {self.dpath}.config/gtk-4.0/bookmarks')
        os.system(f'sudo cp -r {self.dpath}.config/gtk-3.0/bookmarks /root/.config/gtk-3.0/bookmarks')
        os.system(f'sudo cp -r {self.dpath}.config/gtk-3.0/bookmarks /root/.config/gtk-4.0/bookmarks')
    def copy_fish(self):
        os.system(f'cp -r {self.path}config/fish/config.fish {self.dpath}.config/fish/config.fish')
        os.system(f'cp -r {self.path}config/fish/fish_variables {self.dpath}.config/fish/fish_variables')
        with open(f'{self.dpath}.config/fish/config.fish', 'r+') as file:
            content = file.read()
            file.seek(0, 0)
            file.write(f'export PATH="{self.dpath}.local/share/gem/ruby/3.0.0/bin:$PATH"\nexport PATH="{self.dpath}.local/bin:$PATH"\n')
            file.write(content)
